home *** CD-ROM | disk | FTP | other *** search
- Path: dgp.toronto.edu!victorng
- Newsgroups: comp.lang.c++
- From: victorng@dgp.toronto.edu (Victor Ng-Thow-Hing)
- Subject: Code loses this pointer value
- X-Nntp-Posting-Host: explorer.dgp.toronto.edu
- Message-ID: <1996Jan9.021817.24635@jarvis.cs.toronto.edu>
- X-Newsreader: NN version 6.5.0 #3 (NOV)
- Date: 9 Jan 96 07:18:17 GMT
-
- Hi everyone,
-
- I have a particularly nasty bug in my C++ class code. Basically, the code
- loses track of the this pointer value that points to the object that is
- calling a member function. I have a class called bsplinevolume. The
- member function "build_Controlpoints" calls another member function
- "get_Skeleton_samp" as in the following short code snippet:
-
- void bsplinevolume::build_Controlpoints()
- {
- <stuff deleted>
-
- // Assign internal control points and interior cap ends.
- double point[3];
- for (int i=0; i<(N_s1-1); i++)
- for (int j=0; j < N_s2; j++)
- for (int k=0; k < N_s3; k++) {
- get_Skeleton_samp(i,j,k,point); // member function
- set_Controlpoint(i,j,k,point); // member function
- }
-
- <stuff deleted>
- }
-
- When I run dbx on this code, if I type: print *this while in
- build_Controlpoints, I get the proper 'this' value:
-
- (dbx) print *this
- class bsplinevolume {
- N1 = 0x10004858
- N2 = 0x10004908
- N3 = 0x100049c8
- Axis = 0x10004398
- N_axis = 0
- Cap1 = 0x100044c0
- N_cap1 = 0
- Cap2 = 0x10004730
- N_cap2 = 0
- Skeleton_samps = 0x10004a78
- N_s1 = 10
- N_s2 = 10
- N_s3 = 10
- Controlpoints = 0x1000a840
- N_cpts = 1000
- }
-
- NOW, when I print *this while in get_Skeleton_samp, I get:
-
- (dbx) print *this
- <no such address>
-
- and consequently all the variables in this method are full of garbage.
- You can see that 'this' has lost or corrupted its pointer value.
-
- I'm using the CC SGI c++ compiler on an Indigo2 Extreme.
-
- Does anyone have any experience with this bug?
-
- Regards,
- Victor.
-